<div class="full-screen">
  <header>
    <div class="a-bar">
      <a href="javascript:history.back()" class="a-back"><i class="arr left"></i><{t}>返回<{/t}></a>
      <div class="a-name"><{t}>注册<{/t}></div>
      <div class="a-right">
        <a href="<{link app=b2c ctl=wap_passport act=login}>" class="btn orange"><{t}>登录<{/t}></a>
      </div>
    </div>
  </header>
  <div class="full-padding">
    <form action="<{link app=b2c ctl=wap_passport act=create args01=$next_url}>" method="post" class="form" data-type="ajax">
      <input name="forward" type="hidden" value="<{$options.url}>">
      <input name="mini" type="hidden" value="<{$mini_passport}>">
	  <{if $site_sms_valide == 'true'}>
      <div class="c-g">
        <label class="c-l">
          <em class="f-red">*</em><i class="iconfont" title="验证码">&#xe609;</i></label>
        <div class="c">
          <{input type="vcode" name="verifycode" class="verify-input" placeholder=$___b2c="填写验证码"|t:'b2c' key='b2c' key='b2c' label=$___b2c="换一张"|t:'b2c' key='b2c'}>
        </div>
      </div>
      <{/if}>
	  <{if $phones}>
	  <div class="c-g">
		<label for="" class="c-l"><em class="f-red">*</em><i class="iconfont" title="手机号">&#xe60b;</i></label>
		<div class="c">
			<!--手机验证-->
			<select name="pam_account[phone_setting]" id="quhao" style="padding: 10px;">
				<{foreach from=$phones item=items}>
				<option sid="<{$items.length}>" value="<{$items.area}>"><{$items.country}><{$items.area}></option>
				<{/foreach}>
			</select>
		</div>
	  </div>
	  <{/if}>

      <div class="c-g">
        <label for="" class="c-l">
          <{if !$phones}>
			<em class="f-red">*</em><i class="iconfont" title="手机号">&#xe60b;</i>
		  <{/if}>
        </label>
        <div class="c">
          <input type="text" name="pam_account[login_name]" class="text a-account" required="required" autofocus data-caution="<{t}>手机号不能为空<{/t}>"><a href="<{link app=b2c ctl=wap_passport act=send_vcode_sms}>"  class="btn btn-send orange ib-btn btn-new"><{t}>获取登录密码<{/t}></a>
        </div>
      </div>
      <div class="notice"></div>
      <div class="c-g">
        <label for="" class="c-l">
          <em class="f-red">*</em><i class="iconfont" title="密码">&#xe601;</i>
        </label>
        <div class="c">
          <input type="password" name="pam_account[login_password]" maxlength="20" placeholder="<{t}>请输入您收到的短信登录密码<{/t}>" required="required" pattern=".{6,20}" class="text" data-caution="<{t}>密码不能为空<{/t}>">
        </div>
      </div>
      <div class="notice"></div>
      <div class="c-g-c">
        <input type="checkbox" name="license" id="license" checked="checked">
        <label for="license">
          <{t}>同意<{/t}><a href="<{link app=b2c ctl=wap_passport act=license}>" class="license lnk"><{t}>注册协议<{/t}></a>
        </label>
      </div>
      <div class="btn-bar">
        <button type="submit" class="btn orange" rel="_request"><{t}>注册并登陆<{/t}></button>
      </div>
    </form>
  </div>
</div>
<script>
$('.form .btn-send').click(function (e) {
    e.preventDefault();
    var el = $('.form .a-account');
    if($(this).hasClass('disabled')) return false;
	var req_data = 'uname=' + el.val() + '&type=signup';
	var obj = $("#quhao option:selected");
	var phone_setting = '';
	if(obj && obj[0])
	{
		phone_setting = obj[0].value.replace("+","%2B");
		req_data = req_data + '&phone_setting=' + phone_setting;
	}

    <{if $site_sms_valide == 'true'}>
    var verify = $('.verify-input');
    if(verify[0].value == '')
    {
      alert('<{t}>请输入验证码<{/t}>');
      return;
    }
	req_data = req_data + '&type=signup&sms_vcode=' + verify[0].value;
    <{/if}>
	sendVerify(this, req_data);
});

function sendVerify(el, data) {
    var url = el.href;
    $(el).addClass('disabled');
    var cd = new countdown(el, {
        start: 120,
        secondOnly: true,
        callback: function(e) {
            $(el).removeClass('disabled').html('<{t}>重发密码<{/t}>');
        }
    });
    $.post(url, data, function(rs) {
        if(rs) {
            try{
                rs = $.parseJSON(rs);
            } catch (e) {}
            if(rs.error) {
                $(el).removeClass('disabled').html('<{t}>重发密码<{/t}>');
                clearTimeout(cd.timer);
                if(typeof rs.error === 'string') alert(rs.error);
            }
        }
    });
}
</script>
